package com.dome.testgallery.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;

public class TestAdapter extends BaseAdapter{

	private Context context;
	private List<Integer> list;
	
	public TestAdapter(Context ct, List<Integer> list){
		this.context = ct;
		this.list = list;
	}
	
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {
		
		ImageView imageView = new ImageView(context);
		imageView.setBackgroundResource(list.get(position));
		imageView.setScaleType(ScaleType.FIT_XY);
		imageView.setLayoutParams(new Gallery.LayoutParams(Gallery.LayoutParams.FILL_PARENT
				, Gallery.LayoutParams.WRAP_CONTENT));
		return imageView;
	}

}
